<template>
  <div class="content">
    <div class="top">
      <span>商家拒绝退款</span>
      <p>您可以选择再次申请退款</p>
    </div>
    <div class="text">
      <span>商家拒绝理由</span>
      <p>{{refudForm.refuseContent}}</p>
    </div>
    <div class="info">
      <div class="img-box">
        <img :src="form.goodsImage" mode="scaleToFill" />
        <p>{{form.goodsName}}</p>
      </div>
      <div class="info-box" v-for="(item,index) in refudList" :key="index">
        <span>{{item.label}}</span>
        <p :class="{red:item.isMoney}">{{item.value}}</p>
      </div>
      <div class="btn-box">
        <button @click="stockreFund">再次申请</button>
      </div>
    </div>
  </div>
</template>

<script>
import { FIND_REFUD_PAGE } from '@/api'
import { getCurrentPageParams } from '@/utils'

export default {
  components: {},
  data () {
    return {
      form: {},
      refudForm: {}
    }
  },
  created () {},
  computed: {
    account () {
      return this.$cookie.get('account')
    },
    refudList () {
      return [
        {
          label: '退款原因：',
          value: this.refudForm.reason,
          isMoney: false
        },
        {
          label: '退款金额：',
          value: `￥ ${(
            (this.refudForm.lockAmount + this.refudForm.amount) *
            1
          ).toFixed(2)}`,
          isMoney: true
        },
        {
          label: '申请时间：',
          value: this.refudForm.createDate,
          isMoney: false
        },
        {
          label: '退款编号：',
          value: this.refudForm.tradeNo,
          isMoney: false
        }
      ]
    }
  },
  onShow () {
    this.init()
  },
  methods: {
    stockreFund () {
      const vm = this
      let str = JSON.stringify(vm.form)
      vm.$router.push(
        `/pages/data-analyze/stock/my/apply-money/main?item=${str}`
      )
    },
    init () {
      let item = JSON.parse(getCurrentPageParams('item'))
      this.form = item
      console.log(this.form)
      this.findRefudPage()
    },
    /** API **/
    findRefudPage () {
      const vm = this
      let params = {
        orderNo: vm.form.orderNo
      }
      FIND_REFUD_PAGE(params, 1, 999)
        .then(r => {
          if (r.data.code === '0') {
            vm.refudForm = r.data.data.list[0]
            console.log(this.refudForm.createDate)
          } else {
            vm.$toast(r.data.message)
          }
        })
        .catch(e => {
          console.info(e)
        })
    }
  }
}
</script>

<style lang="scss">
.content {
  width: 100%;
  height: 100%;
  background: #fff;
  > .top {
    font-size: 18px;
    color: #101010;
    padding: 15px 20px;
    border-bottom: 5px solid #efefef;
    border-top: 1px solid #efefef;
    > p {
      margin-top: 10px;
      font-size: 14px;
      color: #ec2f19;
    }
  }
  > .text {
    font-size: 15px;
    color: #101010;
    padding: 18px 15px 42px;
    border-bottom: 1px solid #efefef;
    > p {
      color: #717171;
    }
  }
  > .info {
    font-size: 15px;
    color: #101010;
    padding: 18px 15px 42px;
    margin-bottom: 5px;
    > .img-box {
      display: flex;
      border-bottom: 1px solid #efefef;
      margin-bottom: 20px;
      padding-bottom: 10px;
      > img {
        width: 50px;
        height: 50px;
        margin-right: 28px;
      }
    }
    > .info-box {
      display: flex;
      align-items: center;
      color: #797979;
      margin: 13px 0;
      padding: 0 15px 0;
      > p {
        &.red {
          color: #ec2f19;
        }
      }
    }
    > .btn-box {
      margin-top: 20px;
      width: 100%;
      display: flex;
      justify-content: flex-end;
      > button {
        width: 80px;
        height: 24px;
        border-radius: 25px;
        color: #ec2f19;
        border: 1px solid #ec2f19;
        font-size: 12px;
        line-height: 24px;
        background: #fff;
        margin: 0;
        padding: 0;
      }
    }
  }
}
</style>
